package com.example.hospital.controller;

import com.example.common.util.annotation.CustomApiImplicitParam;
import com.example.common.util.core.controller.BaseController;
import com.example.common.util.core.page.TableDataInfo;
import com.example.common.util.core.resultbody.AjaxResult;
import com.example.hospital.service.HospitalSetService;
import com.example.model.domain.entity.hospital.HospitalSet;
import com.example.model.vo.hospital.HospitalSetQueryVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 医院设置Controller
 *
 * @author ruoyi
 * @date 2021-07-08
 */
@Api(tags = "医院设置管理")
@RestController
@RequestMapping("/admin/hospital/hospitalSet")
public class HospitalSetController extends BaseController
{
    @Autowired
    private HospitalSetService hospitalSetService;

    /**
     * 查询医院设置列表
     */
    @ApiOperation(value = "查询医院设置列表")
    @GetMapping("/list")
    public AjaxResult list()
    {
        List<HospitalSet> list = hospitalSetService.selectHospitalSetList();
        return AjaxResult.success(list);
    }


    /**
     * 查询医院设置列表分页
     */
    @ApiOperation(value = "查询医院设置列表分页")
    @PostMapping("/page/{pageNum}/{pageSize}")
    public AjaxResult page(@PathVariable Integer pageNum, @PathVariable Integer pageSize,@RequestBody HospitalSetQueryVo hospitalSetQueryVo)
    {
        PageHelper.startPage(pageNum,pageSize);
        List<HospitalSet> page = hospitalSetService.selectHospitalSetList(hospitalSetQueryVo);
        PageInfo<HospitalSet> hospitalSetPageInfo = new PageInfo<>(page);
        return AjaxResult.success(hospitalSetPageInfo);
    }


    /**
     * 获取医院设置详细信息
     */
    @ApiOperation(value = "获取医院设置详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hospitalSetService.selectHospitalSetById(id));
    }

    /**
     * 新增医院设置
     */
    @ApiOperation(value = "新增医院设置")
    @PostMapping
    public AjaxResult add(@RequestBody HospitalSet hospitalSet)
    {
        return toAjax(hospitalSetService.insertHospitalSet(hospitalSet));
    }

    /**
     * 修改医院设置
     */
    @ApiOperation(value = "修改医院设置")
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalSet hospitalSet)
    {
        return toAjax(hospitalSetService.updateHospitalSet(hospitalSet));
    }

    /**
     * 删除医院设置
     */
    @ApiOperation(value = "删除医院设置")
//    @ApiImplicitParam(name = "ids", value = "医院设置id集合" , allowMultiple = true, dataType = "Long")
    @CustomApiImplicitParam(name = "ids",value = "医院设置id集合")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hospitalSetService.deleteHospitalSetByIds(ids));
    }

    @ApiOperation(value = "医院锁定和解锁")
    @PutMapping("locked/{id}/{status}")
    public AjaxResult locked(@PathVariable Long id, @PathVariable Integer status)
    {
        return toAjax(hospitalSetService.hospitalSetLocked(id,status));
    }

}
